package com.sihan.swvp.dao.sys;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.sihan.swvp.dao.BaseDao;
import com.sihan.swvp.entity.sys.Menu;
import com.sihan.swvp.entity.sys.User;

public interface MenuDao extends BaseDao {
	
	//@Select("select id,pid,sys_menu.index,sys_menu.text,linktype,link,leaf,CONCAT('menu/getIcon?id=',id) icon from sys_menu t where pid=#{node} order by t.index")
//	@Select("SELECT id,pid,t.index,t.text,linktype,link,leaf,CONCAT('menu/getIcon.do?id=',id) as icon FROM sys_menu t WHERE pid=#{node} ORDER BY t.index")
	List<Map<String, Object>> getMenuByParent(@Param("user")Long user,@Param("node")String node);

//	@Select("SELECT id,pid,t.index,t.text,linktype,link,leaf,CONCAT('menu/getIcon.do?id=',id) as icon FROM sys_menu t WHERE leaf=0 and pid=#{node} ORDER BY t.index")
	List<Map<String, Object>> getFolderByParent(@Param("node")String node);
	
	int addMenu(Map<String, Object> params);
	
	int updateMenu(Map<String, Object> params);

	@Select("select * from sys_menu t where id=#{id}")
	public Menu getIcon(@Param("id")String id);

	public void deleteMenu(@Param("id")String id,@Param("user")Long user);
	
	public long[] getAllPrivIds(User user);
	
	public List<Map<String, Object>> getMenu3(@Param("user")Long user);
	
	public List<Map<String, Object>> getNavigationMenu(@Param("user")Long user);
	
	/**
	 * 添加个人菜单信息
	 * @param params
	 * @return
	 */
	int addUserMenu(Map<String, Object> params);
	
	/**
	 *根据用户查询个人菜单定制信息
	 * @param user
	 * @return
	 */
	public List<Map<String, Object>> getUserMenu(@Param("user")Long user);
	
	public void delUserMenu(@Param("userId") Long userId,@Param("menuId") String menuId);
	
	/**
	 * 个人菜单信息排序
	 * @param params
	 * @return
	 */
	int updateUserMenuSort(Map<String, Object> params);
	
	/**
	 * 个人菜单定制信息验证
	 * @param params
	 * @return
	 */
	public Map<String, Object> getUserMenuValidate(Map<String, Object> params);
	
	/**
	 * 根据菜单ID删除个人菜单定制信息
	 * @param menuid 菜单ID
	 * @return
	 */
	int deleteUserMenu(Map<String, Object> params);
	
	/**
	 * 根据名称查询次菜单中是否存在同名的菜单
	 * @return
	 */
	public int getMenuByNameCounts(@Param("text") String text);
	
	public List<Map<String, Object>> getMenuByUserId(Long userid);
}
